<?php
/**
 * Created by PhpStorm.
 * User: nhson219
 * Date: 10/15/2014
 * Time: 11:38 AM
 */
?>
<script src="<?php echo base_url()?>/app/js/star-rating.min.js" type="text/javascript"></script>
<?php
if((isset($userCate) == TRUE) && (count($userCate) > 0)){ $dem = 0;
?>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 list-dev-recommended no-padding">
    <?php
    foreach($userCate as $item){ $dem++;
        if(!empty($UserInvited)) {
            if (in_array($item->id, $UserInvited)) {
                $Invited = "Invited";
            }else{
                $Invited = "";
            }
        }else{
            $Invited = "";
        }
        ?>
        <div data-id="<?php echo $item->id?>" data-placement='above' class="col-lg-3 col-md-3 col-sm-3 col-xs-12 item-dev-recommend <?php echo $Invited?>">
            <div class="col-lg-5 col-md-4 col-sm-4 col-xs-12 no-padding"><img class="img-responsive" src="<?php
                if ( (is_file_exists($item->logo) == TRUE ) && ($item->logo != "")) echo uimage_url($item->logo); else echo image_default();
                ?>" /></div>
            <div class="col-lg-7 col-md-8 col-sm-8 col-xs-12 no-padding-right" style="margin-top: 8px;">
                <span><?php echo $item->user_name;?></span>
                <span><input value="<?php echo $item->user_rating?>" type="number" data-star-captions="{}" data-default-caption="{rating}" class="rating" min=0 max=5  data-size="xs" disabled></span>
                <button type="button" data-href="<?php echo site_url("userList/inviteOneProgrammer/".$item->id."/".$projectId)?>" id="btn-invite-one"  class="btn btn-primary btn-invite"><?php echo $this->lang->line('Invite')?></button>
            </div>
            <div id="popover_info_dev_1" data-toggle="popover_info_dev" style="display: none" class="col-lg-12">
                <div class="col-lg-4">

                </div>
                <div class="col-lg-12 col-sm-12 col-md-12 col-xs-12">
                    <div><?php //echo getCountry($single_user['country_id'])->row()->country_name;
                        $result = getCountry($item->country_id);
                        if($result->num_rows() > 0)
                            echo $result->row()->country_name;
                        ?></div>

                    <div><?php echo $item->num_reviews?> reviews</div>
                    <div>2 jobs</div>
                    <div>Levels 5</div>
                    <div>Tỷ lệ hoàn thành 100%</div>
                </div>
            </div>
        </div> <!--            item-dev-recommend-->
        <?php if($dem % 4 == 0) echo "<div class='clear'></div>"; } ?>
    <?php } ?>
</div>
<script>
    $(document).ready(function(){
        $(".rating").rating('refresh',{showCaption:true,clearCaption:'0'});
        $(".item-dev-recommend").each(function(){
            if($(this).hasClass('Invited')){
                //$(this).addClass('item-dev-recommend-opacity');
                $(this).css('cursor','no-drop');
                $(this).off('click');
                $(this).find('.btn-invite').text('Invited');
                $(this).find('.btn-invite').prop('disabled',true);
                $(this).append('<span class="glyphicon glyphicon-ok green-2"></span>');
            }else{
                $(this).find('.btn-invite').prop('disabled',false);
            }
        });
    });
    $('.item-dev-recommend').popover({
        html: true,
        trigger: 'manual',
        placement: 'bottom',
        content: function () {
            return $('#popover_info_dev_1').html();
        }
    }).on("mouseenter", function () {
        var _this = this;
        $(this).popover("show");
        $(this).siblings(".popover").on("mouseleave", function () {
            $(_this).popover('hide');
        });
    }).on("mouseleave", function () {
        var _this = this;
        setTimeout(function () {
            if (!$(".popover:hover").length) {
                $(_this).popover("hide")
            }
        }, 100);
    });
</script>